<template>
  <div class="box_wrapper">
    <GlobalPriceLimit ref="limitRef" :typePrice="1" @save="save" />
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import GlobalPriceLimit from "@/components/GlobalPriceLimit/index.vue";
import {
  setGlobalVipPrice,
  getGlobalVipPrice,
} from "@/api/operateCenter/global/index";

const limitRef = ref();

const save = () => {
  setGlobalVipPrice(limitRef.value.vipList).then(() => {
    ElMessage.success("保存成功");
    getVip();
  });
};

// 获取vip价格阶梯
const getVip = () => {
  getGlobalVipPrice().then((res: Record<string, any>) => {
    // 获取vip价格数组传递给子组件
    limitRef.value.vipList = res || [];
  });
};

onMounted(() => {
  getVip();
});
</script>
<style scoped lang="scss">
.box_wrapper {
  min-height: calc(100vh - 90px);
  padding: 0 20px;
  padding-top: 20px;
  background-color: #fff;
}
</style>
